#include <slothttpd/ref_counted.hpp>
#include <slothttpd/connection.hpp>

#include <typeinfo>

namespace slothttpd {

ref_counted::ref_counted() :
    ref_count_(0)
{
}

ref_counted::ref_counted(connection_ptr conn) :
    c(conn),
    ref_count_(0)
{
}

ref_counted::~ref_counted()
{
}

void intrusive_ptr_add_ref(ref_counted *r) noexcept
{
    r->ref_count_++;
}

void intrusive_ptr_release(ref_counted *r) noexcept
{
    r->ref_count_--;
    
    if (r->ref_count_ == 0) {
        r->~ref_counted();
    }
}

}
